package com.caigou.service.impl;

import com.caigou.bean.cms.param.ChannelHotSearchPrams;
import com.caigou.enums.ResponseEnum;
import com.caigou.mapper.cms.ChannelHotSearchMapper;
import com.caigou.service.ChannelHotSearchService;
import com.caigou.service.ChannelMenuService;
import com.caigou.util.Result;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ChannelHotSearchServiceImpl implements ChannelHotSearchService {

    @Resource
    private ChannelMenuService channelMenuService;

    @Resource
    private ChannelHotSearchMapper channelHotSearchMapper;

    @Override
    public Result loadChannelHotSearchData(ChannelHotSearchPrams prams) {
        return Result.success(channelHotSearchMapper.loadChannelHotSearchData(prams.getPlateId()));
    }

    @Override
    public Result updateChannelHotSearchData(ChannelHotSearchPrams prams) {
        prams.getChannelHotSearchList().forEach(item -> channelHotSearchMapper.updateChannelHotSearchData(item));
        return Result.success(ResponseEnum.SUCCESS);
    }

    @Override
    public Result loadUpdateOption() {
        return Result.success(channelMenuService.loadUpdateOptionIds());
    }
}
